class Solution
{
public:
    int computeArea(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2)
    {
        long long x1 = max(ax1, bx1);
        long long y1 = max(ay1, by1);
        long long x2 = min(ax2, bx2);
        long long y2 = min(ay2, by2);
        long long x = x2 - x1;
        long long y = y2 - y1;
        long long ax = ax2 - ax1;
        long long ay = ay2 - ay1;
        long long bx = bx2 - bx1;
        long long by = by2 - by1;
        long long overlapArea = 0;
        if (x > 0 && y > 0)
        {
            overlapArea = x * y;
        }
        return ax * ay + bx * by - overlapArea;
    }
};